import {
  Inject,
  Controller,
  Get,
  Post,
  Query,
  Body,
} from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
import { DynamicDTO } from '../dto/dynamic';
import { DynamicService } from '../service/dynamic.service';
@Controller('/api')
export class DynamicController {
  @Inject()
  ctx: Context;

  @Inject()
  dynamicService: DynamicService;

  /**
   * 发动态
   */
  @Post('/sendDynamic')
  async sendDynamic(@Body() dynamic: DynamicDTO): Promise<any> {
    const result = await this.dynamicService.sendDynamic(dynamic);
    return result;
  }

  /**
   * 获取全部动态
   */
  @Get('/getAllDynamic')
  async getAllDynamic(): Promise<any> {
    const result = await this.dynamicService.getAllDynamic();
    return result;
  }

  /**
   * 获取自己或别人动态
   */
  @Get('/getDynamic')
  async getDynamic(@Query('id') id: number): Promise<any> {
    const result = await this.dynamicService.getDynamic(id);
    return result;
  }

  /**
   * 删除动态
   */
  @Post('/deleteDynamic')
  async deleteDynamic(@Body('id') id: number): Promise<any> {
    const result = await this.dynamicService.deleteDynamic(id);
    return result;
  }

  /**
   * 动态点赞
   */
  @Post('/dynamicStar')
  async dynamicStar(): Promise<any> {
    const result = await this.dynamicService.dynamicStar();
    return result;
  }

  /**
   * 动态评论
   */
  @Post('/dynamicComment')
  async dynamicComment(): Promise<any> {
    const result = await this.dynamicService.dynamicComment();
    return result;
  }

  /**
   * 获取动态评论
   */
  @Get('/getDynamicComment')
  async getDynamicComment(): Promise<any> {
    const result = await this.dynamicService.getDynamicComment();
    return result;
  }
}
